<template>
  <div>
    <van-nav-bar
        title="评价"
        left-text="返回"
        left-arrow
        @click-left="onClickLeft"
    />
    <van-panel :title="m_title">
        <div>
            <van-cell-group>
            <van-field v-model="text"
                placeholder="请输入评价内容"
                maxlength="125"
                show-word-limit
                label-width="100px"
                class="van-multi-ellipsis--l3"
                type="textarea"
            />
            </van-cell-group>
            <van-divider content-position="left">评分</van-divider>
            <van-rate
                v-model="number1"
                allow-half
                void-icon="star"
                void-color="#eee"
             />
        </div>
        <div slot="footer">
            <van-button size="small" type="danger" @click="Ping(text,number1)">提交</van-button>
            <van-button size="small" @click="back">返回</van-button>
        </div>
    </van-panel>
  </div>
</template>

<script>
// 引入提示组件
import { Toast } from "vant";
import { Field } from 'vant';
export default {
  data() {
    return {
        m_title:'',
        o_id:'',
        text:'',
        number1:0,
        showWordLimit:true,
        c_time:'',
        u_img:''
    };
  },
  mounted(){
      this.m_title=this.$route.query.m_title;
      this.o_id=this.$route.query.o_id;
      this.u_img=sessionStorage.getItem('u_img');
      let username= sessionStorage.getItem('username');
            if(!username){
              var that=this;
                Toast({
                message:'请先登录',
                duration:1000,
                onClose:function(){
                    that.$router.push('/login');
                }
                });
            }
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1);
    },
    back(){
      this.$router.go(-1);

    },
    Ping(text,number1){
      let username= sessionStorage.getItem('username');
      let yy = new Date().getFullYear();
      let mm = new Date().getMonth()+1;
      let dd = new Date().getDate();
      let hh = new Date().getHours();
      let mf = new Date().getMinutes()<10 ? '0'+new Date().getMinutes() : new Date().getMinutes();
      let ss = new Date().getSeconds()<10 ? '0'+new Date().getSeconds() : new Date().getSeconds();
      this.c_time = yy+'-'+mm+'-'+dd+' '+hh+':'+mf+':'+ss;
        this.text=text;
        this.number1=number1;
        this.axios.post('http://www.shop.com:8080/api.php/common/getOrdersEdit?access_token=5b7f60aca7e7f6f8c680b1b219ad3ec6&&o_id='+this.o_id+'&&p_status=1')
        .then(res=>{
        })
        this.axios.post('http://www.shop.com:8080/api.php/common/getPingjiaAdd?access_token=5b7f60aca7e7f6f8c680b1b219ad3ec6&&u_name='+username+'&&m_title='+this.m_title
        +'&&describe='+this.text+'&&start='+number1+'&&c_time='+this.c_time+'&&u_img='+this.u_img)
        .then(res=>{
          Toast({
                message:res.data.msg,
                duration:1000,
            });
             this.$router.push('/order');
        })
      
    },
  }
};
</script>

<style scoped>
.van-nav-bar .van-icon,
.van-nav-bar__title,
.van-nav-bar__text {
  color: #000;
}
.reg {
  width: 300px;
  margin: 50px auto;
}
.reg h1 {
  font-family: "华文新魏";
  color: brown;
}
.Pjia{
    widows: 60px;
    height: 80px;
}
</style>
